﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core;
using COFE.Core.Profile;
using System.IO;

namespace COFE.Core.Lister
{
    public class StreamProviderBase<T> : IStreamProvider
    {
        #region Constructor

        public StreamProviderBase(IDirectoryLister lister)
        {
            ListerKey = lister.ListerKey;
        }

        #endregion

        #region Methods        

        protected T getEmbeddedItem(IInternalFileSystemInfoExA entry)
        {
            return EntryUtils.GetEmbeddedEntry<T>(entry);
        }

        public virtual Stream OpenStream(IInternalFileInfoExA file, FileMode mode, FileAccess access, FileShare share)
        {
            T embeddedEntry = getEmbeddedItem(file);
            return _getStream(embeddedEntry, mode, access, share);
        }

        #endregion

        #region Data

        protected Func<T, FileMode, FileAccess, FileShare, Stream> _getStream =
            (file, mode, access, share) => { throw new NotImplementedException(); };        


        #endregion

        #region Public Properties

        public string ListerKey { get; private set; }


        #endregion





    }
}
